package nio;

import java.nio.IntBuffer;
import java.security.SecureRandom;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName NioTestOne.java
 * @Description TODO
 * @createTime 2020年04月22日 20:31:00
 */
public class NioTestOne {
	public static void main(String[] args) {
		IntBuffer buffer = IntBuffer.allocate(10);
		for (int i = 0; i < 5; i++) {
			int nextInt = new SecureRandom().nextInt(20);
			buffer.put(nextInt);
		}
		System.out.println("before flip limit"+buffer.limit());
		buffer.flip();
		System.out.println("after flip limit"+buffer.limit());
		while (buffer.hasRemaining()) {
			System.out.println("position"+buffer.position());
			System.out.println("limit"+buffer.limit());
			System.out.println("capacity"+buffer.capacity());
			System.out.println(buffer.get());
		}
	}
}
